package com.tanhua.server.controller;

import com.baomidou.mybatisplus.annotation.TableName;
import com.tanhua.domain.vo.RecommendUserQueryVO;
import com.tanhua.server.service.TanhuaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author liuyp
 * @date 2021/01/29
 */
@RestController
@RequestMapping("/tanhua")
public class TanhuaController {
    @Autowired
    private TanhuaService tanhuaService;

    /**
     * 交友-今日佳人
     * GET /tanhua/todayBest
     */
    @GetMapping("/todayBest")
    public ResponseEntity todayBest(){
        return tanhuaService.todayBest();
    }

    /**
     * 交友-推荐佳人（推荐朋友）
     * GET /tanhua/recommendation
     */
    @GetMapping("/recommendation")
    public ResponseEntity recommendation(RecommendUserQueryVO queryVO){
        return tanhuaService.findRecommendUserList(queryVO);
    }

    /**
     * 交友-查看佳人信息
     * GET /tanhua/:id/personalInfo
     */
    @GetMapping("/{id}/personalInfo")
    public ResponseEntity findPersonalInfo(@PathVariable("id") Long targetUserId){
        return tanhuaService.findPersonalInfo(targetUserId);
    }

    /**
     * 交友-查看佳人的陌生人问题
     * GET /tanhua/strangerQuestions
     */
    @GetMapping("/strangerQuestions")
    public ResponseEntity findStrangerQuestions(Long userId){
        return tanhuaService.findStrangerQuestions(userId);
    }

    /**
     * 交友-回复对方的陌生人问题
     * POST /tanhua/strangerQuestions
     */
    @PostMapping("/strangerQuestions")
    public ResponseEntity replyStrangerQuestions(@RequestBody Map map){
        Long targetUserId = Long.valueOf(map.get("userId").toString());
        String reply = (String) map.get("reply");
        return tanhuaService.replyStrangerQuestions(targetUserId, reply);
    }

    /**
     * 交友-搜附近
     * GET /tanhua/search
     */
    @GetMapping("/search")
    public ResponseEntity searchNear(@RequestParam(required = false) String gender, Integer distance){
        return tanhuaService.searchNear(gender, distance);
    }
}
